package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

const (
	BufferSize = 1024 * 20
)

func ReadLine(filename string) []string {
	lines := []string{}
	f, err := os.Open(filename)
	if err != nil {
		fmt.Println(err)
		return nil
	}
	defer f.Close()
	r := bufio.NewReaderSize(f, BufferSize)
	if err != nil {
		fmt.Println(err)
		return nil
	}
	line, isPrefix, err := r.ReadLine()
	for err == nil && !isPrefix {
		s := string(line)
		if len(s) > 0 {
			lines = append(lines, s)
		}
		line, isPrefix, err = r.ReadLine()

	}

	if isPrefix {
		fmt.Println("buffer size to small")
		return nil
	}
	if err != io.EOF {
		fmt.Println(err)
		return nil
	}

	return lines
}
